package com.lxw.mq;


import com.lxw.MqConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


//监听队列
@Slf4j
@Component
public class MqTest {

    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.TEST_QUEUE)
    public void process1(String msg){
        System.out.println(msg+"111");

    }

    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.TEST_QUEUE)
    public void process2(String msg){
        System.out.println(msg +"222");

    }

    /**
     * 订阅模式
     */
    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.FANOUT1)
    public void process3(String msg){
        System.out.println(msg);

    }
    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.FANOUT2)
    public void process4(String msg){
        System.out.println(msg);

    }

    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.EXCHANGE_DIRECT_INFO)
    public void process5(String msg){
        System.out.println(msg);

    }


    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.TOPIC_INFO0)
    public void process6(String msg){
        System.out.println(msg+"t0");

    }

    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.TOPIC_INFO1)
    public void process7(String msg){
        System.out.println(msg+"t1");

    }

    @RabbitHandler
    //监听队列
    @RabbitListener(queues = MqConst.TOPIC_INFO2)
    public void process8(String msg){
        System.out.println(msg+"t2");

    }
}
